﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nox.Amuse.Model;
using System.Windows.Input;
using Nox.Amuse.MVVM;

namespace Nox.Amuse.ViewModel
{
    public class CommandHistoryItemViewModel
    {
        /// <summary>
        /// The string that was in the input box when the command was recorded
        /// </summary>
        public string OriginalString
        {
            get { return myModel.OriginalString; }
        }

        /// <summary>
        /// The date and time it was added to the command history
        /// </summary>
        public string TimeRecorded
        {
            get { return myModel.TimeRecorded.ToLongTimeString(); }
        }

        /// <summary>
        /// Indicates if the command was placed in the history without being sent to the server
        /// </summary>
        public bool IsUnsent
        {
            get { return myModel.IsUnsent; }
        }

        private CommandHistoryItem myModel;

        public CommandHistoryItemViewModel(CommandHistoryItem model)
        {
            myModel = model;
        }

        private CommandHistoryViewModel myParent;

        public void RegisterParent(CommandHistoryViewModel parent)
        {
            myParent = parent;
        }


        public ICommand RecallCommand
        {
            get
            {
                return myRecallCommand ?? (myRecallCommand = new RelayCommand(
                    () =>
                    {
                        myParent.ChildRecallCommand();
                    }
                    ));
            }
        }
        private RelayCommand myRecallCommand;

    }
}
